From 4170c8bf2c436513956fdaf9cfa9e5d02a42b240 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 13 Jul 2016 01:37:22 +0100 Subject: [PATCH] fanotify: Taint on use of FANOTIFY_ACCESS_PERMISSIONS Various free and proprietary AV products use this feature and users apparently want it. But punting access checks to userland seems like an easy way to deadlock the system, and there will be nothing we can do about that. So warn and taint the kernel if this feature is actually used. Gbp-Pq: Topic debian Gbp-Pq: Name fanotify-taint-on-use-of-fanotify_access_permissions.patch --- fs/notify/fanotify/fanotify_user.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index ec4d8c59d0e..7e393ed0da2 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -865,6 +865,14 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, if (mask & ~valid_mask) return -EINVAL; +#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS + if (mask & FAN_ALL_PERM_EVENTS) { + pr_warn_once("%s (%d): Using fanotify permission checks may lead to deadlock; tainting kernel\n", + current->comm, current->pid); + add_taint(TAINT_USER, LOCKDEP_STILL_OK); + } +#endif + f = fdget(fanotify_fd); if (unlikely(!f.file)) return -EBADF; -- 2.30.2